package com.cxs.componentcode.slice;

import com.cxs.componentcode.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.utils.Rect;
import ohos.bundle.ElementName;
import ohos.global.icu.text.CaseMap;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

import java.time.temporal.ValueRange;

public class MainAbilitySlice extends AbilitySlice {
    static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP, 0x00101, "MainAbility");
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        Button btn_tab_list = (Button) findComponentById(ResourceTable.Id_btn_tab_list);
        btn_tab_list.setClickedListener(mListenner);

        Button btn_list_container = (Button) findComponentById(ResourceTable.Id_btn_list_container);
        btn_list_container.setClickedListener(mListenner);
    }

    Component.ClickedListener mListenner = new Component.ClickedListener() {
        @Override
        public void onClick(Component component) {
            switch (component.getId()) {
                case ResourceTable.Id_btn_tab_list: {
                    present(new TabListSlice(), new Intent());
                    break;
                }
                case ResourceTable.Id_btn_list_container:{
                    HiLog.info(LABEL, "Id_btn_list_container");
                    present(new ListContainerSlice(), new Intent());
                    break;
                }
            }

        }
    };

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
